package com.example.hehecat.yuejian1.mvp.model;

import com.example.hehecat.yuejian1.http.RetrofitHttp;
import com.example.hehecat.yuejian1.mvp.contract.ActivityInfoContract;
import com.example.hehecat.yuejian1.mvp.model.bean.ActivityBean;
import com.example.hehecat.yuejian1.mvp.model.bean.SuccessBean;

import okhttp3.OkHttpClient;
import retrofit2.Callback;
import rx.Subscriber;
import rx.android.schedulers.AndroidSchedulers;
import rx.schedulers.Schedulers;

public class ActivityInfoModel implements ActivityInfoContract.Model {
    @Override
    public void getActivity(int activity_id, Subscriber<ActivityBean> subscriber) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).getActivityInfo(activity_id)
                .subscribeOn(Schedulers.newThread())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(subscriber);
    }

    @Override
    public void activityEnroll(int activity_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).activityEnroll(user_id, activity_id)
                .enqueue(callback);
    }

    @Override
    public void collectActivity(int activity_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).collectActivity(user_id, activity_id)
                .enqueue(callback);
    }

    @Override
    public void isActivityCollect(int activity_id, int user_id, Callback<SuccessBean> callback) {
        OkHttpClient.Builder builder = new OkHttpClient.Builder();
        RetrofitHttp.getRetrofit(builder).isActivityCollect(user_id, activity_id)
                .enqueue(callback);
    }
}
